import storage from "@/utils/storage";

const state = {
    userInfo: storage.get("userInfo"),
    token: storage.get("token"),
    tabActive: '/home',
};
const mutations = {
    setUserInfo(state, data) {
        storage.set("token", data.token || "");
        storage.set("userInfo", data);
        state.userInfo = data;
        state.token = data.token;
    },
    setOutLogin(state) {
        storage.remove("token");
        storage.remove("userInfo");
        state.userInfo = "";
        state.token = "";
    },
    setTabActive(state, data) {
        state.tabActive = data
    }
};
const getters = {

    userInfoGetter: (state) => state.userInfo,
    tokenGetter: (state) => state.token,
    tabActiveGetter: (state) => state.tabActive,

};
const actions = {};

export default {
    name: "user",
    state,
    mutations,
    getters,
    actions,
};
